<template>
  <view class="flex-col">

    <view :class="boole?'bottom115':''">
      <!--基础信息-->
      <view v-for="(item,index) in detailForm.tableData" :key="index">
        <basic-info :ruleForm="item"/>
      </view>


      <!--装饰预算-->


    </view>

    <!--审批流程-->
    <exam-flow v-if="flowId" :instanceId="flowId"/>

    <view class="button-container" v-if="boole">
      <button class="btn-item" @click="submit">提 交</button>
    </view>

  </view>
</template>

<script>
import {getRenewalDetails,submitRenewal} from "@/api/renewal";
import basicInfo from './components/basicInfo.vue'
export default {
  name: 'add',
  components:{basicInfo},
  computed: {},
  watch: {},
  data() {
    return {
      boole: false,
      flowId: null,
      detailForm: {
        tableData:[]
      },
    };
  },
  onLoad(op) {
    let title = "";
    this.flowId = op?.flowId;
    this.detailForm.carId = op?.carId
    this.detailForm.workId = op?.id
    this.detailForm.workOrderStatus = "2"
    if (op?.type === "edit") {
      title = "处理续保信息";
      this.boole = true;
    }
    this.handleDetail([op?.id])
    this.detailForm.carId = op?.carId;
    uni.setNavigationBarTitle({
      title,
    });
  },
  methods: {
    //获取详情
    handleDetail(id) {
      getRenewalDetails(id).then((res) => {
        if (res.code === 200) {
          this.detailForm.tableData = res.data;
        }
      });
    },

    async submit(){
      try {
        uni.showLoading();
        // await this.$refs.refInspectionInfo.handleEffect()
        let res = await submitRenewal(this.detailForm)
        if (res.code === 200) {
          this.$modal.msgSuccess("提交成功");
          setTimeout(() => {
            this.$tab.navigateBack();
          }, 1000);
        }
      } catch (error) {
        if (typeof error === 'string') {
          this.$nextTick(() => {
            uni.pageScrollTo({
              selector: error,
            });
          });
        } else {
          console.error(error)
        }
      } finally {
        uni.hideLoading();
      }
    }
  },
};
</script>

<style scoped lang=""></style>


